package com.igfd.tanmao.mapper;

import com.igfd.tanmao.pojo.TamllOrderDetail;
import com.igfd.tanmao.pojo.TanmaoItem;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.Date;

@Mapper
public interface TanmaoOrderDetailMapper {

    @Insert("insert into tanmao_order_detail(tid, oid, title, num_iid, sku_id, totalQuantity, price, total_fee, payment, discount_fee, adjust_fee, sku_properties_name, created_at, updated_at) values(#{tid}, #{oid}, #{title}, #{numIid}, #{skuId}, #{totalQuantity}, #{price}, #{totalFee}, #{payment}, #{discountFee}, #{adjustFee}, #{skuPropertiesName}, #{createdAt}, #{updatedAt})")
    int add(@Param("tid") String tid, @Param("oid") String oid, @Param("title") String title, @Param("numIid") String numIid, @Param("skuId") String skuId, @Param("totalQuantity") String totalQuantity, @Param("price") String price, @Param("totalFee") String totalFee, @Param("payment") String payment, @Param("discountFee") String discountFee, @Param("adjustFee") String adjustFee, @Param("skuPropertiesName") String skuPropertiesName, @Param("createdAt") Date createdAt, @Param("updatedAt") Date updatedAt);

    @Select("select count(*) from tanmao_order_detail where tid = #{tid} and oid = #{oid} and num_iid = #{numIid} and sku_id = #{skuId}")
    int findTanmaoOrderDetailCount(@Param("tid") String tid,@Param("oid") String oid,@Param("numIid") String numIid, @Param("skuId") String skuId);

    @Select("select * from tanmao_order_detail where tid = #{tid}")
    ArrayList<TamllOrderDetail> findTamllOrderDetailByTid(@Param("tid") String tid);

}
